package ui.panels.commands;

import javax.swing.JFrame;

import Data.ConfigurationParameters;

import ui.flowManager.expirimentProperties.ExperimentProperties.Agent_Group;
import ui.panels.distributionPanels.DistributionFrame;
import ui.panels.distributionPanels.ExponentialDistributionPanel;
import ui.panels.distributionPanels.NormalDistributionPanel;
import gameEngine.agents.distrebution.representation.FixedRepresentation;
import gameEngine.agents.distrebution.representation.UniformRepresentation;

public class DistributionFrameCommand implements Command{

	private String 		distribution	= null;
	private int 		gameNumber = 0;
	private int 		playerNumber = 0;
	private Agent_Group group = null;
	
	public void execute()
	{
		//check that the params was not forgotten to be set
		if((distribution != null) && (group != null))
		{
			//case normal
			if(distribution.equals(ConfigurationParameters.Distribution.NORMAL))
			{
				DistributionFrame frame = new DistributionFrame(distribution);
				frame.add(new NormalDistributionPanel(frame, gameNumber, playerNumber, group));
				frame.repaint();
			}
			//case Exponential
			else if(distribution.equals(ConfigurationParameters.Distribution.EXPONENTIAL))
			{
				DistributionFrame frame = new DistributionFrame(distribution);
				frame.add(new ExponentialDistributionPanel(frame, gameNumber, playerNumber, group));
				frame.repaint();
			}

			//case Fixed
			else if(distribution.equals(ConfigurationParameters.Distribution.FIXED))
			{
				// have not parameters , GUI not needed
				
				//update the new distribution in Player Properties Panel
				FixedRepresentation fixedRepresentation = new FixedRepresentation(distribution);
				//use another command for the update
				SetDistRepresentationCommand setDistRepresentationCommand = new SetDistRepresentationCommand();
				setDistRepresentationCommand.setDistRepresentation(fixedRepresentation);
				setDistRepresentationCommand.setGroup(group);
				setDistRepresentationCommand.execute();
			}		
			
			//case Uniform
			else if(distribution.equals(ConfigurationParameters.Distribution.UNIFORM))
			{
				// have not parameters , GUI not needed
				
				//update the new distribution in Player Properties Panel
				UniformRepresentation unRepresentation = new UniformRepresentation(distribution);
				//use another command for the update
				SetDistRepresentationCommand setDistRepresentationCommand = new SetDistRepresentationCommand();
				setDistRepresentationCommand.setDistRepresentation(unRepresentation);
				setDistRepresentationCommand.setGroup(group);
				setDistRepresentationCommand.execute();
			}				
			
		}
		//end first if 
	}

	public void setDistribution(String distribution) {
		this.distribution = distribution;
	}

	public void setGameNumber(int gameNumber) {
		this.gameNumber = gameNumber;
	}

	public void setPlayerNumber(int playerNumber) {
		this.playerNumber = playerNumber;
	}

	public void setGroup(Agent_Group group) {
		this.group = group;
	}
}
